﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：StructrueInformationInfo
// 文件功能描述：岗位管理
//
// 
// 创建标识：2012-08-06 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class StructrueInformationInfo
    {
        public int structrueId
        {
            get;
            set;
        }

        public string structrueName
        {
            get;
            set;
        }
        private DataAccessStructrueInformation dar;

        public StructrueInformationInfo()
        {
            dar = new DataAccessStructrueInformation();
        }

        /// <summary>
        /// 获取岗位信息（分页）
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public IList<StructrueInformationInfo> SelInfo(int pagesize, int startindex, string strquery, out int count)
        {
            IList<StructrueInformationInfo> grolist = new List<StructrueInformationInfo>();
            StructrueInformationInfo groinfo;
            DataSet ds = dar.SelInfo(pagesize, startindex, strquery, out count);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                groinfo = new StructrueInformationInfo()
                {
                    structrueId = Convert.ToInt32(item["structrueId"]),
                    structrueName = item["structrueName"].ToString()
                };
                grolist.Add(groinfo);
            }
            return grolist;
        }

        /// <summary>
        /// 保存岗位(新增界面下)
        /// </summary>
        /// <param name="rolepara"></param>
        /// <returns></returns>
        public int SaveStructrueInformation(StructrueInformationInfo gro)
        {
            object[] gropara = new object[] { gro.structrueName };
            return dar.SaveStructrueInformation(gropara);
        }

        /// <summary>
        /// 根据编号获取一条岗位信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public StructrueInformationInfo GetStructrueInformationInfoOne(string id)
        {
            dar = new DataAccessStructrueInformation();
            DataSet ds = dar.GetStructrueInformationInfoOne(id);
            StructrueInformationInfo info = new StructrueInformationInfo();
            info.structrueId = int.Parse(ds.Tables[0].Rows[0]["structrueId"].ToString());
            info.structrueName = ds.Tables[0].Rows[0]["structrueName"].ToString();
            return info;
        }

        /// <summary>
        /// 保存岗位(修改界面下)
        /// </summary>
        /// <param name="rolepara"></param>
        /// <returns></returns>
        public int SaveStructrueInformationEdit(StructrueInformationInfo gro)
        {
            object[] gropara = new object[] { gro.structrueId, gro.structrueName };
            return dar.SaveStructrueInformationEdit(gropara);
        }

        /// <summary>
        /// 删除岗位
        /// </summary>
        /// <param name="roleid"></param>
        /// <returns></returns>
        public int DeleteStructrueInformation(string id)
        {
            return dar.DeleteStructrueInformation(id);
        }
    }
}
